package cn.org.xwb.common.encrypt.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList;
import java.util.List;

public class DecryptUtil {

    /**
     * 对字符串数组列表进行 rsa 密钥解密
     * @param strList
     * @param rsaPrivateKey
     * @return
     */
    public static List<String> strListRsaDe(List<String> strList, String rsaPrivateKey) {
        try {
            List<String> deStrList = new ArrayList<>();
            for (String s : strList) {
                // 解密
                deStrList.add(RsaUtilWithFront.decryptByPrivateKey(rsaPrivateKey, s));
            }
            return deStrList;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
